package com.xl6667.controller;

import com.xl6667.domain.ResponseResult;
import com.xl6667.domain.dto.AddArticle;
import com.xl6667.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/content/article")
public class articleController {
    @Autowired
    private ArticleService articleService;

    /**
     * 显示所有文章
     * @param pageNum
     * @param pageSize
     * @param title
     * @param content
     * @return
     */
    @GetMapping("/list")
    public ResponseResult getArticleList(Integer pageNum,Integer pageSize,String title,String content){
        return articleService.getArticleList(pageNum,pageSize,title,content);
    }

    @DeleteMapping("{ids}")
    public ResponseResult delArticleList(@PathVariable List<Long> ids){
        return articleService.delArticleList(ids);
    }
    /**
     * 新增博文
     */

    @PostMapping
    public ResponseResult addArticle(@RequestBody AddArticle addarticle){
        return articleService.addArticle(addarticle);
    }
    /**
     * 回显博文
     */
    @GetMapping("{id}")
    public ResponseResult getSysArticle(@PathVariable Long id){
        return articleService.getSysArticle(id);
    }

    /**
     * 修改
     * @param addArticle
     * @return
     */
    @PutMapping
    public ResponseResult putArticle(@RequestBody AddArticle addArticle){
        return articleService.putArticle(addArticle);
    }



}
